#============================================
#知识点
#1.三元表达式
#2.列表生成式
#3.各种生成式
#4.注意没有元组生成式
#============================================   
#三元表达式结构:条件成立返回值 if 条件 else 条件不成立返回值
# a = 1
# b = 2
# print(a if a>b else b)
#============================================   
#列表生成式结构:表达式 for i in 可迭代对象 if 条件（空的默认为if True）
# ls =["abc1","qwq1","fdf","sdfsd","sdf1","wdf","sdaf1","df"]
# print([i.upper() for i in ls ])
# print([i for i in ls if i[-1:]=="1"])
# print([i[:-1] for i in ls if i[-1:]=="1"])
#============================================  
#字典生成式
# ls = ["qwq","awa","cvc"]
# ls1 = [("小黑",1),("小绿",2),("小红",3)]
# print({i:"伞兵" for i in ls})
# print({i:j for i,j in ls1 if i!="小红"})
#============================================  
#生成器生成式
# ls = [1,2,3,4,5,6,7,8,9]
# ddq = (i for i in ls if i >2)
# print(ddq)
# # for i in range(len(ls)):
# #     print(next(ddq))
# for i in ddq:
#     print(i)

#重点!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
#sun(可迭代对象)
# #假如一个文件有上万行，要想计算它的总字符数，要想节省空间就可以用到生成器生成式
# f="asdasdasddddddddddddddd" #假设文件有很多字符
# g=(len(i) for i in f)  #每计算一个调用一次next的返回值,起到占内存少的作用
# print(sum(g))          #只占用了一个内存地址
#============================================
# a = 1
# b = 2
# print(123) if a > b else print('qwq')
#
# s = [i**2 for i in range(20)]
# print(s)

# s = (i for i in range(20))
# print(next(s))
# print(next(s))
# print(next(s))
# print(next(s))
# print(next(s))

# s = {i:'qwq' for i in range(10)}
# print(s)